<template>
  <div>
    <FilterTable
      ref="table"
      selectionType="single"
      height="300"
      :isToperInfo="false"
      :isColumnFilter="false"
      :columns="columns"
      :dataSource="tableList"
      :onRowSelectChange="selectChangeHandle"
      :onColumnsChange="columns => (this.columns = columns)"
    >
    </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <!-- <el-button @click="closeDrawer(2)" type="primary">确 定</el-button> -->
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { detailInfo } from '@/api/omFinance/MoneyManage/AccountManage';
import { getDealerUser } from '@/api/omFinance';

export default {
  mixins: [dictionary],
  props: ['rowData'],
  data() {
    return {
      columns: this.createdTable(),
      tableList: [],
      tableData: [],
      deptDictList: []
    };
  },
  created() {
    // this.getUser();
    this.getDetailInfo();
  },
  methods: {
    // async getUser() {
    //   let res = await getDealerUser();
    //   let empList = res.data.map(x => ({ text: x.userName, value: x.userId + '' }));
    //   this.columns.find(item => item.dataIndex === 'createdBy').editItems = empList; //操作姓名
    //   this.columns.find(item => item.dataIndex === 'createdBy').filterItems = empList;
    // },
    async getDetailInfo() {
      const res = await detailInfo(this.rowData.id);
      if (res.resultCode == 200) {
        this.tableList = res.data;
      }
    },
    selectChangeHandle(rows) {
      this.tableData = JSON.parse(JSON.stringify(rows));
    },

    closeDrawer(type) {
      if (type == 1) {
        return this.$emit('close', false);
      }
      if (type == 2) {
        return this.$emit('close', false, this.tableData);
      }
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '单据流水编号',
          dataIndex: 'id',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商代码',
          dataIndex: 'ownerCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商简称',
          dataIndex: 'ownerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '预扣金额',
          dataIndex: 'freezeAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '销售订单号',
          dataIndex: 'doNo',
          sorter: true,
          filter: true,
          filterType: 'input',
          align: 'center',
          width: 200
        },
        {
          title: '产品代码',
          dataIndex: 'productCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '产品名称',
          dataIndex: 'productName',
          align: 'center',
          width: 400,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '预扣时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '操作人',
          dataIndex: 'createdByName',
          sorter: true,
          filter: true,
          filterType: 'input'
          // filterType: 'checkbox',
          // filterItems: [],
          // editType: 'select',
          // editItems: []
        }
      ];
    }
  }
};
</script>
